<?php ini_set("precision","2"); ?>
<?php
         $a = Doctrine::getTable('BbPlayerStat')->getAvgStatsBySeason($seasonId, $orderByColumn, $order)
?>
<?php $season = Doctrine::getTable('BbSeason')->findOneBySId($seasonId); ?>
<?php $league = Doctrine::getTable('BbLeague')->findOneById($season->getLId())?>
<?php $odd=1;?>
<div class="column-left">
<div class="news-title"><?php echo $league." :: ".$season ?></div>	
<div class="mod-container mod-table">
			<div class="mod-header stathead"><h4>Стат</h4></div>
			<div class="mod-content">
				<table cellspacing="1" cellpadding="3" class="tablehead">
					<tbody>
					<tr align="right" class="colhead">
						<td align="left" style="width:20px;">#</td>
						<td align="left">ТОГЛОГЧ</td>
						<td align="left">БАГ</td>
						<td>   
						<?php 
				              if($order == "desc")
				                echo '&uarr;'.link_to('Т', '@stat_index?seasonId='.$seasonId.'&orderByColumn=gp&order=asc');
				              else 
				                echo '&darr;'.link_to('Т', '@stat_index?seasonId='.$seasonId.'&orderByColumn=gp&order=desc');
	              		?>
	              		</td>
	              		<td>   
						<?php 
				              if($order == "desc")
				                echo '&uarr;'.link_to('PTS', '@stat_index?seasonId='.$seasonId.'&orderByColumn=pts&order=asc');
				              else 
				                echo '&darr;'.link_to('PTS', '@stat_index?seasonId='.$seasonId.'&orderByColumn=pts&order=desc');
	              		?>
	              		</td>
						<td><span title="Оновчтой довтолсон-Нийт довтолсон">FGM-FGA</span></td>
						<td>   
						<?php 
				              if($order == "desc")
				                echo '&uarr;'.link_to('FG%', '@stat_index?seasonId='.$seasonId.'&orderByColumn=fg&order=asc');
				              else 
				                echo '&darr;'.link_to('FG%', '@stat_index?seasonId='.$seasonId.'&orderByColumn=fg&order=desc');
	              		?>
	              		</td>
						<td><span title="Холын зайнаас оновчтой шидсэн-Холын зайнаас нийт шидсэн">3PM-3PA</span></td>
						<td>   
						<?php 
				              if($order == "desc")
				                echo '&uarr;'.link_to('3P%', '@stat_index?seasonId='.$seasonId.'&orderByColumn=3pt&order=asc');
				              else 
				                echo '&darr;'.link_to('3P%', '@stat_index?seasonId='.$seasonId.'&orderByColumn=3pt&order=desc');
	              		?>
	              		</td>
						<td><span title="Оновчтой чөлөөт шидэлт-Нийт чөлөөт шидэлт">FTM-FTA</span></td>
						<td>   
						<?php 
				              if($order == "desc")
				                echo '&uarr;'.link_to('FT%', '@stat_index?seasonId='.$seasonId.'&orderByColumn=ft&order=asc');
				              else 
				                echo '&darr;'.link_to('FT%', '@stat_index?seasonId='.$seasonId.'&orderByColumn=ft&order=desc');
	              		?>
	              		</td>
					</tr>
					
			<?php $i=1; foreach ($a as $key=>$value): ?>
              	<?php $player = Doctrine::getTable('BbPlayers')->findOneById($value['playerId']); ?>
              	<?php $position = Doctrine::getTable('BbPositions')->findOneByPId($player->getPositionId()); ?>
              	<?php $team = Doctrine::getTable('BbTeams')->findOneById($player->getTeamId()); ?>
              	<tr class="<?php if($odd==1) { echo 'odd'; $odd=0; } else { echo 'even'; $odd=1; }?>">
              		 <td align="left" style="width:20px;"><?php echo $i.'. ' ?></td>
              		 <td align="left" ><a href="<?php echo url_for('player/show?seasonId='.$seasonId.'&nick='.$player->getNick())?>"><?php echo $player->getFullname().', ' ?></a><?php echo mb_substr($position, 0, 3, 'UTF-8') ?></td>
	 				 <td align="left"><a href="<?php echo url_for('team/show?seasonId='.$seasonId.'&name='.$team)?>"><?php echo $team ?></a></td>           	
              		 <td class="<?php if($orderByColumn=='gp') echo 'sortcell';?>"><?php echo $value['gp'] ?></td>
              		 <td class="<?php if($orderByColumn=='pts') echo 'sortcell';?>"><?php echo $value['pts'] ?></td>
              		<td><?php echo $value['fgm'].'-'. $value['fga'] ?></td>
              		<td class="<?php if($orderByColumn=='fg') echo 'sortcell';?>"><?php echo $value['fg'].'%' ?></td>
              		<td><?php echo $value['pt3m'].'-'.$value['pt3a'] ?></td>
    				<td class="<?php if($orderByColumn=='3pt') echo 'sortcell';?>"><?php echo $value['3pt'].'%' ?></td>          
              		<td><?php echo $value['ftm'].'-'.$value['fta'] ?></td>             		
              		<td class="<?php if($orderByColumn=='ft') echo 'sortcell';?>"><?php echo $value['ft'].'%' ?></td>             		            		           		
              	</tr>
            <?php $i++; endforeach;?>
            </tbody></table>

		</div>
		<div class="foot-footer"></div>
</div>
	
</div>

<?php include_partial('main/right', array());?>

<br clear="all">
<script type="text/javascript">
 
</script>